<template>
	<el-table :data="movice_list" border style="width: 100%">
		<el-table-column prop="title" label="名字"></el-table-column>
		<el-table-column prop="flash" label="查看"></el-table-column>
		<el-table-column prop="address" label="更新"></el-table-column>
		<el-table-column prop="address" label="操作">
			<template slot-scope="scope">
				<el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
				<el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
			</template>
		</el-table-column>
	</el-table>
</template>

<script>
	const request = require('@/api/movies.js')
	export default {
		name: 'deletemovie',
		data() {
			return {
				movice_list: [],
			}
		},
		created() {
			this.getmovies()
		},
		methods: {
			getmovies() {
				request.getmovies({

				}).then(res => {
					console.log(res)
					this.movice_list = res.data
				})
			},
			handleEdit(index, row) {
				console.log(index, row);
			},
			handleDelete(index, row) {
				console.log(row)
				this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					request.deletemovies({
						id: row._id
					}).then(res => {
						console.log(res)
						this.$message({
							type: 'success',
							message: '删除成功!'
						});
						this.getmovies()
					}).catch(err => {
						this.$message({
							type: 'error',
							message: '删除失败!'
						});
					})
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消删除'
					});
				});
				console.log(index, row);
			},
		},
	}
</script>

<style>

</style>